package com.chen.mqtthandle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Controller;

@Controller
public class TestController {
    @Autowired
    private MqttPahoMessageHandler mqtt;

    public void sendMessage(){
        Message<String> message = MessageBuilder.withPayload("======111111======").setHeader(MqttHeaders.TOPIC,"/topic/test").build();
        mqtt.handleMessage(message);
        System.out.println("success");
    }

}
